<script>

export default {
  name: "UserInfo",
  components: {},
  data() {
    return {
      imageUrl: '',
      form: {
        name: ''
      }
    }
  },
  methods: {
    handleAvatarSuccess(res, file) {
      this.imageUrl = URL.createObjectURL(file.raw);
    },
    beforeAvatarUpload(file) {
      const isJPG = file.type === 'image/jpeg';
      const isLt2M = file.size / 1024 / 1024 < 2;

      if (!isJPG) {
        this.$message.error('上传头像图片只能是 JPG 格式!');
      }
      if (!isLt2M) {
        this.$message.error('上传头像图片大小不能超过 2MB!');
      }
      return isJPG && isLt2M;
    }
  }
}
</script>

<template>
  <div>
    <div class="home-overview">
      <!-- 用户信息 -->
      <div class="user-meta">
        <div class="avatar">
          <img src="../assets/none.png" alt="">
        </div>
        <h4>
          admin <span class="type">普通用户</span>
          <p class="level">用户等级：<span>1vs</span></p>
          <p>积分：<span>12</span></p>
        </h4>
      </div>
      <div class="item">
<!--        <a href="javascript:;">-->
          <span class="iconfont icon-hy"></span>
          <el-button>开通会员</el-button>
<!--        </a>-->
      </div>
    </div>
    <div class="like-container">
      <div class="home-panel">
        <div class="header">
          <h4 data-v-bcb266e0="">我的信息</h4>
        </div>
        <div class="goods-list">
          <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="头像">
              <el-upload
                  class="avatar-uploader"
                  action="https://jsonplaceholder.typicode.com/posts/"
                  :show-file-list="false"
                  :on-success="handleAvatarSuccess"
                  :before-upload="beforeAvatarUpload">
                <img v-if="imageUrl" :src="imageUrl" class="avatar">
                <i v-else class="el-icon-plus avatar-uploader-icon"></i>
              </el-upload>
            </el-form-item>
            <el-form-item label="昵称">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="手机号">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="个性签名">
              <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="性别">
              <el-radio-group v-model="form.name">
                <el-radio :label="3">男</el-radio>
                <el-radio :label="6">女</el-radio>
                <el-radio :label="9">保密</el-radio>
              </el-radio-group>
            </el-form-item>
            <el-form-item label="出生日期">
              <el-date-picker
                  v-model="form.name"
                  type="date"
                  placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button class="save" type="primary" @click="onSubmit">保存</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="css">
.avatar-uploader /deep/.el-upload {
  margin-top: 12px;
  border: 1px dashed #000000;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
.home-overview {
  height: 132px;
  background: url(../assets/center-bg.png) no-repeat center;
  display: flex;
}

.home-overview .user-meta {
  flex: 1;
  display: flex;
  align-items: center;
}

.home-overview .user-meta h4 p {
  margin-top: 13px;
}

.home-overview .user-meta h4 .type {
  font-size: 13px;
  color: #8d43b7;
}

.home-overview .avatar {
  width: 85px;
  height: 85px;
  border-radius: 50%;
  overflow: hidden;
  margin-left: 60px;
}

.home-overview .avatar img {
  width: 100%;
  height: 100%;
}

.home-overview .user-meta h4 {
  padding-left: 26px;
  font-size: 18px;
  font-weight: normal;
  color: white;
}

.home-overview .item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-around;
}

.home-overview:first-child {
  border-right: 1px solid #f4f4f4;
}

.home-overview a {
  color: white;
  font-size: 16px;
  text-align: center;
}

.home-overview a .iconfont {
  font-size: 32px;
}

.home-overview a p {
  line-height: 32px;
}

.like-container {
  margin-top: 20px;
  border-radius: 4px;
  background-color: #fff;
}

.home-panel {
  background-color: #fff;
  padding: 0 20px;
  margin-top: 20px;
  height: 400px;
}

.home-panel .header {
  height: 66px;
  border-bottom: 1px solid #f5f5f5;
  padding: 18px 0;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.home-panel h4 {
  font-size: 22px;
  font-weight: 400;
}

.home-panel .goods-list {
  display: flex;
  justify-content: space-around;
}

.save {
  width: 110px;
  height: 39px;
}

/*头像*/
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>
